<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div>
            <textarea cols="40" rows="10" v-model="textValue"></textarea>
            <button @click="add">按钮</button>
        </div>
        <div>
            <div v-for="(item,index) in content">
                <span>{{item.item}}</span>
                <button @click="addCount(index)">点赞</button>
                <span>{{item.count}}</span>
                <button @click="top(index)">置顶</button>
                <button @click="del(index)">删除</button>
            </div>
        </div>
        <div><a href="./2.html">第二个页面</a></div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                content: [],
                textValue: ''
            },
            methods: {
                add() {
                    let obj = { item: this.textValue, count: 0 }
                    this.content.push(obj)
                },
                addCount(addValue) {
                    this.content[addValue].count++;
                },
                top(topValue) {
                    this.content.unshift(this.content.splice(topValue, 1)[0])
                },
                del(delValue) {
                    this.content = this.content.filter(function (item, index) {
                        return delValue != index
                    })
                }
            },
            computeds: {

            }
        })
    </script>
</body>

</html>